package me.sdevil507.org.mapper;

import me.sdevil507.org.dto.OrgRoleResourceRelResultDto;
import me.sdevil507.org.po.OrgRoleResourceRelPo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 平台角色表[OrgRoleResourceRelPo]
 *
 * @author sdevil507
 * created on 2020-06-23 18:15:44
 */
@Component
@Mapper(componentModel = "spring")
public interface OrgRoleResourceRelMapper {

    /**
     * po => dto
     *
     * @param po 实体类
     * @return dto传输类
     */
    @Mapping(source = "role.id", target = "roleId")
    @Mapping(source = "resource.id", target = "id")
    @Mapping(source = "resource.code", target = "code")
    OrgRoleResourceRelResultDto po2dto(OrgRoleResourceRelPo po);

    /**
     * pos => dtos
     *
     * @param pos 实体类集合
     * @return dtos传输类集合
     */
    List<OrgRoleResourceRelResultDto> pos2dtos(List<OrgRoleResourceRelPo> pos);

    /**
     * dto => po
     *
     * @param dto 传输类
     * @return po实体类
     */
    @Mapping(source = "roleId", target = "role.id")
    @Mapping(source = "id", target = "resource.id")
    @Mapping(source = "code", target = "resource.code")
    OrgRoleResourceRelPo dto2po(OrgRoleResourceRelResultDto dto);

    /**
     * dtos => pos
     *
     * @param dtos 传输类集合
     * @return pos实体类集合
     */
    List<OrgRoleResourceRelPo> dtos2pos(List<OrgRoleResourceRelResultDto> dtos);

}